{include file="pageheader.htm"}
{insert_scripts files="../js/utils.js,validator.js"}

<div class="tab-div">
    <!-- tab bar -->
    <div id="tabbar-div">
      <p>
        <span class="tab-front" id="general-tab">{$lang.tab_general}</span><span
        class="tab-back" id="goods-tab">{$lang.bind_goods}</span>
      </p>
    </div>

    <!-- tab body -->
    <div id="tabbody-div">
    	<form action="" method="post" name="theForm" submit="validate()">
		    <table cellspacing="1" cellpadding="3" width="100%" id="general-table">
		      <tr>
		        <td class="label">{$lang.lab_group_name}</td>
		        <td><input type="text" name="collect_name" value="{$collect.name}" size="40" />
		        {$lang.require_field}</td>
		      </tr>
		    </table>
		 
		    <table cellspacing="1" cellpadding="3" width="100%" id="goods-table" style="display:none;">
		      <tr>
	              <td class="label">{$lang.lab_goods_type}</td>
	              <td>
	                <select name="goods_type" onchange="getAttrList()" autocomplete="off">
	                  <option value="0">{$lang.sel_goods_type}</option>
	                  {$goods_type_list}
	                </select>
	              </td>
	          </tr>
		      <tr>
	              <td class="label">{$lang.lab_goods_attr}</td>
	              <td>
	                <select id="goods_attr" name="goods_attr" onchange="getGoodsList()" autocomplete="off">

	                  {$goods_attr_list}
	                </select>
	              </td>
	          </tr>
	          <tr>
	            <td id="tbody-goods" colspan="2" style="padding:0">{$goods_list_html}</td>
	          </tr>
		    </table>
		    <div class="button-div">
		    	<input type="hidden" name="collect_id" value="{$collect.id}" />
		        <input type="submit" value="{$lang.button_submit}" class="button" />
		        <input type="reset" value="{$lang.button_reset}" class="button" />
		        <input type="hidden" name="act" value="{$form_act}" />
		    </div>
		 </form>
    </div>
</div>

<script type="text/javascript">


{literal}

onload = function() {
  document.forms['theForm'].elements['collect_name'].focus();
  startCheckOrder();
}

function validate()
{
  var validator = new Validator('theForm');
  validator.required('collect_name', group_name_not_null);

  return validator.passed();

}

function getAttrList()
{
    var selGoodsType = document.forms['theForm'].elements['goods_type'];

    if (selGoodsType != undefined)
    {
        var goodsType = selGoodsType.options[selGoodsType.selectedIndex].value;

        Ajax.call('goods_group.php?act=get_attr_list', "goods_type=" + goodsType, setAttrList, "GET", "JSON");
    }
}

function setAttrList(result, text_result)
{
	document.getElementById('goods_attr').innerHTML=result.content;
	
}

function getGoodsList()
{
    var selGoodsType = document.forms['theForm'].elements['goods_type'];
    var selGoodsAttr = document.forms['theForm'].elements['goods_attr'];
    var collectId = document.forms['theForm'].elements['collect_id'].value;
    
    if ( selGoodsType != undefined && selGoodsAttr != undefined )
    {
        var goodsType = selGoodsType.options[selGoodsType.selectedIndex].value;
        var goodsAttr = selGoodsAttr.options[selGoodsAttr.selectedIndex].value;

        Ajax.call('goods_group.php?act=get_goods_list',
        		"goods_type=" + goodsType + "&goods_attr=" +goodsAttr + "&collect_id=" + collectId, setGoodsList, "GET", "JSON");
    }
}

function setGoodsList(result, text_result)
{
  document.getElementById('tbody-goods').innerHTML = result.content;
}

{/literal}  

</script>
{insert_scripts files="tab.js"}
{include file="pagefooter.htm"}